<?php

session_start();
require_once('../include/MySugarApplication.php');
require_once("../include/User.php");
$app->checkSession('Users/Form.php', $server_unique_key);

$actionType = isset($_REQUEST['actionType']) ? $_REQUEST['actionType'] : "";

$id = "";
$first_name = "";
$last_name = "";
$user_name = "";
$status = "";
$date_modified = "";


if ($actionType == "UPDATE") {
	$query=' users.id = "'.$_REQUEST["id"].'"';
	$orderby = '';

	$rows = $component->getRecord($query);

	foreach($rows as $record) {

		$id = $record["id"];
		$first_name = $record["first_name"];
		$last_name = $record["last_name"];
		$user_name = $record["user_name"];
		$status = $record["status"];
		$date_modified = $record["date_modified"];
	}
}




?>
<!DOCTYPE HTML SYSTEM "http://www.bitzermobile.com/bitzer/dtd/HTML401-loose-bitzer.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<?php
		if (!$isBitzer) {
        	echo '
			<title>MySugar Users</title>
			<LINK REL=StyleSheet HREF="',$app->appRoot,'include/style.css" TYPE="text/css" MEDIA=screen>
        <script type="text/javascript" src="',$app->appRoot,'include/niftycube.js"></script>
        <script type="text/javascript">
            window.onload=function(){
				var formWidth = "550px";
				setAppRoot("',$app->appRoot,'");
                Nifty("div#container");
                Nifty("div#content,div#nav","same-height small");
                Nifty("div#header,div#footer","small");
                Nifty("ul.postnav a","transparent");
				setWidth("div#container", formWidth);
				setWidth("div#content", formWidth);
				setWidth("div#footer", formWidth);

				var riWidth = "550px";
                Nifty("div#riContainer");
                Nifty("div#riContent,div#nav","same-height small");
                Nifty("div#riHeader,div#riFooter","small");
                Nifty("ul.postnav a","transparent");
				setWidth("div#riContainer", riWidth);
				setWidth("div#riContent", riWidth);
				setWidth("div#riFooter", riWidth);
            }
        </script>';
        } else {
			echo '<title></title>';
		}
			?>
    </head>
    <body>
    	<?php
		if (!$isBitzer) {
			echo '
        <div id="container">
            <div id="header">
				<table width="100%">
					<tr>
						<td width="95%"><h1>Users</h1></td>
						<td align="right" width="5%"><a href="',$app->appRoot,'Logout.php">Logout</a></td>
					</tr>
				</table>
			</div>
            <div id="content">
                <h3>Please enter contact info.</h3>';
		}
		?>
                <form name="Users"
                      data-bitzer-title="User"
                      data-bitzer-desc="Users List"
                      data-bitzer-type="COMPONENT"
                      data-bitzer-internal="true"
                      data-bitzer-data-url="<?php echo $app->appRoot ?>Users/Data.php"
		      data-bitzer-sync-scheme="WEBAPP_SOFT"
                      data-bitzer-pagination="true"
                      data-bitzer-online-only="false"
                      data-bitzer-read-only="true"
                      data-bitzer-auto-sync="false"
                      action="noaction" method="post"
                      enctype="application/x-www-form-urlencoded">
                    <input type="hidden" name="id" value="<?php echo $id ?>"
                           data-bitzer-primary-key="true"
                           data-bitzer-type="string">

<?php
if (!$isBitzer) {
?>
                    <table class="form" width="100%">
                        <tr>
                            <th width="27%">
                                <div align="left">
                                    First Name
                                </div>
                            </th>
                            <td>
<?php
}
?>
                                <input data-bitzer-label="First Name"
                                       data-bitzer-short-label="First name"
                                       data-bitzer-type="string"
                                       type="text" name="first_name"
                                       size="50"
                                       value="<?php echo $first_name ?>" >
<?php
if (!$isBitzer) {
?>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <div align="left">
                                    Last Name
                                </div>
                            </th>
                            <td>
<?php
}
?>
                                <input data-bitzer-label="Last Name"
                                       data-bitzer-short-label="Last name"
                                       data-bitzer-type="string"
                                       type="text" name="last_name"
                                       size="50"
                                       value="<?php echo $last_name ?>">
<?php
if (!$isBitzer) {
?>
                            </td>
                        </tr>
                        <tr>
                            <th width="27%">
                                <div align="left">
                                    Username
                                </div>
                            </th>
                            <td>
<?php
}
?>
                                <input data-bitzer-label="Username"
                                       data-bitzer-short-label="Username"
                                       data-bitzer-type="string"
                                       type="text" name="user_name"
                                       size="50"
                                       value="<?php echo $user_name ?>">
<?php
if (!$isBitzer) {
?>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <div align="left">
                                    Status
                                </div>
                            </th>
                            <td>
<?php
}
?>
                                <input data-bitzer-label="Status"
                                       data-bitzer-short-label="Status"
                                       data-bitzer-type="string"
                                       type="text" name="status"
                                       size="50"
                                       value="<?php echo $status ?>">
<?php
if (!$isBitzer) {
?>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <div align="left">
                                    Last Modified On
                                </div>
                            </th>
                            <td>
<?php
}
?>
                                <input data-bitzer-label="Modified On"
                                       data-bitzer-help-text="The record was last modified on this date."
                                       data-bitzer-type="datetime"
                                       readonly
                                       type="text" name="last_modified_on" value="<?php echo $date_modified ?>" >
<?php
if (!$isBitzer) {
?>
                            </td>
                        </tr>
                    </table>

                    <br>
                    <table>
                        <tr>
                            <td>
                                <ul class="postnav">
                                    <li><a href="Data.php">Cancel</a></li>
                                </ul>
                            </td>
                        </tr>
                    </table>
<?php
}
?>
                </form>
<?php
if (!$isBitzer) {
?>
            </div>
            <div id="footer"></div>
        </div>
<?php
}
?>
    </body>
</html>
